package com.gouqi.mall.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * URL地址工具
 * @author:小费
 * @time:2020-2-17
 */
public class URLUtils {

    /**
     * 获取：协议+ip+端口号
     * @param request
     * @return 协议+ip+端口号
     */
    public static String getOrigin(HttpServletRequest request ){
        //System.out.println("获取协议request.getScheme()():"+request.getScheme());
        //System.out.println("获取本地主机localhost或者ip request.getServerName():"+request.getServerName());
        //System.out.println("获取端口request.getServerPort():"+request.getServerPort());
        //System.out.println("获取端口request.getServerPort():"+request.getProtocol());
        String scheme = request.getScheme();
        String serverName = request.getServerName();
        Integer port = request.getServerPort();
        return scheme+"://"+serverName+":"+port;
    }
}
